/*
Copyright [2020] [https://www.xiaonuo.vip]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：

1.请不要删除和修改根目录下的LICENSE文件。
2.请不要删除和修改Snowy源码头部的版权声明。
3.请保留源码和相关描述文件的项目出处，作者声明等。
4.分发源码时候，请注明软件出处 https://gitee.com/xiaonuobase/snowy-layui
5.在修改包名，模块名称，项目代码等时，请注明软件出处 https://gitee.com/xiaonuobase/snowy-layui
6.若您的项目无法满足以上几点，可申请商业授权，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package vip.xiaonuo.sys.modular.question.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vip.xiaonuo.sys.modular.question.entity.Achievement;
import vip.xiaonuo.sys.modular.question.entity.Bigquestionfo;
import vip.xiaonuo.sys.modular.question.mapper.BigquestionfoMapper;
import vip.xiaonuo.sys.modular.question.service.BigquestionfoService;

import javax.annotation.Resource;


/**
 * 大题记录表service接口实现类
 *
 * @author lxc
 * @date 2024-06-19 15:30:24
 */
@Service
public class BigquestionfoServiceImpl extends ServiceImpl<BigquestionfoMapper, Bigquestionfo> implements BigquestionfoService {
    @Resource
    BigquestionfoMapper bigquestionfoMapper;
    @Override
    public void saveByExamId(Achievement achievement) {
        bigquestionfoMapper.saveByExamId(achievement);
    }

    @Override
    public void deleteByExemId(Achievement achievement) {
        bigquestionfoMapper.deleteByExemId(achievement);
    }
    @Override
    public void updateStateById(Achievement achievement){
        bigquestionfoMapper.updateStateById(achievement);
    }

    /*@Override
    public PageResult<Bigquestionfo> page(BigquestionfoParam bigquestionfoParam) {
        QueryWrapper<Bigquestionfo> queryWrapper = new QueryWrapper<>();
        if (ObjectUtil.isNotNull(bigquestionfoParam)) {

            // 根据试卷ID 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getTestpaperId())) {
                queryWrapper.lambda().eq(Bigquestionfo::getTestpaperId, bigquestionfoParam.getTestpaperId());
            }
            // 根据记录ID 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getExaminationrecordId())) {
                queryWrapper.lambda().eq(Bigquestionfo::getExaminationrecordId, bigquestionfoParam.getExaminationrecordId());
            }
            // 根据试题ID 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getQuestionsId())) {
                queryWrapper.lambda().eq(Bigquestionfo::getQuestionsId, bigquestionfoParam.getQuestionsId());
            }
            // 根据用户名 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getUsername())) {
                queryWrapper.lambda().eq(Bigquestionfo::getUsername, bigquestionfoParam.getUsername());
            }
            // 根据考生答案 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getUseranswer())) {
                queryWrapper.lambda().eq(Bigquestionfo::getUseranswer, bigquestionfoParam.getUseranswer());
            }
            // 根据正确答案 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getCorrectanswer())) {
                queryWrapper.lambda().eq(Bigquestionfo::getCorrectanswer, bigquestionfoParam.getCorrectanswer());
            }
            // 根据作答结果 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getResult())) {
                queryWrapper.lambda().eq(Bigquestionfo::getResult, bigquestionfoParam.getResult());
            }
            // 根据得分 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getScore())) {
                queryWrapper.lambda().eq(Bigquestionfo::getScore, bigquestionfoParam.getScore());
            }
            // 根据试题类型 查询
            if (ObjectUtil.isNotEmpty(bigquestionfoParam.getType())) {
                queryWrapper.lambda().eq(Bigquestionfo::getType, bigquestionfoParam.getType());
            }
        }
        return new PageResult<>(this.page(PageFactory.defaultPage(), queryWrapper));
    }

    @Override
    public List<Bigquestionfo> list(BigquestionfoParam bigquestionfoParam) {
        return this.list();
    }

    @Override
    public void add(BigquestionfoParam bigquestionfoParam) {
        Bigquestionfo bigquestionfo = new Bigquestionfo();
        BeanUtil.copyProperties(bigquestionfoParam, bigquestionfo);
        this.save(bigquestionfo);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(List<BigquestionfoParam> bigquestionfoParamList) {
        bigquestionfoParamList.forEach(bigquestionfoParam -> {
        Bigquestionfo bigquestionfo = this.queryBigquestionfo(bigquestionfoParam);
            this.removeById(bigquestionfo.getBigquestionfoId());
        });
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void edit(BigquestionfoParam bigquestionfoParam) {
        Bigquestionfo bigquestionfo = this.queryBigquestionfo(bigquestionfoParam);
        BeanUtil.copyProperties(bigquestionfoParam, bigquestionfo);
        this.updateById(bigquestionfo);
    }

    @Override
    public Bigquestionfo detail(BigquestionfoParam bigquestionfoParam) {
        return this.queryBigquestionfo(bigquestionfoParam);
    }

    *//**
     * 获取大题记录表
     *
     * @author lxc
     * @date 2024-06-19 15:30:24
     *//*
    private Bigquestionfo queryBigquestionfo(BigquestionfoParam bigquestionfoParam) {
        Bigquestionfo bigquestionfo = this.getById(bigquestionfoParam.getBigquestionfoId());
        if (ObjectUtil.isNull(bigquestionfo)) {
            throw new ServiceException(BigquestionfoExceptionEnum.NOT_EXIST);
        }
        return bigquestionfo;
    }*/
}
